from pydantic import BaseModel, Field
from typing import Optional, List, Dict, Any


class Idiom(BaseModel):
    id: int


class IdiomCreate(BaseModel):
    word: str = Field(example="一心一意")
    pinyin: str = Field(example="yī dīng bù shí")
    abbr: Optional[str] = Field('', example="ydbs")
    explanation: Optional[str] = Field('', example="释义")
    quote: Optional[Dict[str, Any]] = Field({}, example="{}")
    source: Optional[Dict[str, Any]] = Field({}, example="{}")
    example: Optional[Dict[str, Any]] = Field({}, example="{}")
    usage: Optional[str] = Field('', example="用法")
    story: Optional[List[str]] = Field([], example="['']")
    similar: Optional[List[str]] = Field([], example="['']")
    opposite: Optional[List[str]] = Field([], example="['']")


class IdiomUpdate(BaseModel):
    id: int
    word: str = Field(example="一心一意")
    pinyin: str = Field(example="yī dīng bù shí")
    abbr: Optional[str] = Field('', example="ydbs")
    explanation: str = Field('', example="释义")
    quote: Optional[Dict[str, Any]] = Field({}, example="{}")
    source: Optional[Dict[str, Any]] = Field({}, example="{}")
    example: Optional[Dict[str, Any]] = Field({}, example="{}")
    usage: Optional[str] = Field('', example="用法")
    story: Optional[List[str]] = Field([], example="['']")
    similar: Optional[List[str]] = Field([], example="['']")
    opposite: Optional[List[str]] = Field([], example="['']")
